<template>
	<view class="page">
		<view class="info_box_base">
			<view class="info_box_base_title" style="font-weight: bold;">巡检工作包：{{baseInfo.work_package_title}}</view>
			<view class="info_box_base_item">巡检方式：电话巡检</view>
			<view class="info_box_base_item">工单说明：<text class="base_item_dd">{{baseInfo.work_orderdesc}}</text></view>
			<view class="info_box_base_item">工单时间 ：{{baseInfo.create_time}}</view> 
		</view>
		<view class="kcsj_box"  v-if="list.length > 0">
			<view class="kcsj_box_item" v-for="(item,index) in list" >
				<view class="kcsj_box_item_top">
					<view class="kcsj_box_item_top_left">
						站点名称:{{item.title}}
					</view>
					<view class="kcsj_box_item_top_right" v-if="item.status == 0" @click="gotoInfo(item)">
						<view class="kcsj_box_item_top_right_btn">待处理</view>
						<u-icon name="arrow-right" color="rgb(119, 119, 119)" size="16"></u-icon>
					</view>
					<view class="kcsj_box_item_top_right" v-if="item.status == 1" >
						<view class="kcsj_box_item_top_right_btn">待审核</view>
						<u-icon name="arrow-right" color="rgb(119, 119, 119)" size="16"></u-icon>
					</view>
					<view class="kcsj_box_item_top_right"  v-if="item.status == 2">
						<view class="kcsj_box_item_top_right_btn" style="border: 1px solid rgb(100, 200, 80);color:rgb(100, 200, 80)">通过</view>
						<u-icon name="arrow-right" color="rgb(100, 200, 80)" size="16"></u-icon>
					</view>
					<view class="kcsj_box_item_top_right" v-if="item.status == 3" @click="gotoInfo(item)">
						<view class="kcsj_box_item_top_right_btn">拒绝</view>
						<u-icon name="arrow-right" color="rgb(119, 119, 119)" size="16"></u-icon>
					</view>
					
				</view>
				<view class="kcsj_box_item_bottom">
					创建时间:{{item.create_time}}
				</view>
			</view> 
		</view>
		<view v-else style="font-size: 25rpx;text-align: center;margin: 40rpx;">暂无新任务</view>
	</view>
</template>

<script>
	import {
		api,
		apiBaseUrl,
		http
	} from '@/config/common.js'
	export default {
		data() {
			return {
				id: '',
				packid: '',
				baseInfo:{},

				page: 1,
				last_page: 1,
				list: [],
			}
		},
		components: {},
		filters: {},
		mounted() {},
		onLoad(e) { 
			this.id = e.id
			this.packid = e.work_package_id
			this.getBaseInfo()
		},
		onReachBottom() {
			if (this.page < this.last_page) {
				this.page = this.page + 1
				this.initList()
			} else {
				console.log('到底了')
			}
		},
		onPullDownRefresh() {
			this.page = 1
			this.list = []
			this.initList()
		},
		onShow() {
			this.page = 1
			this.list = []
			this.initList()
		},
		onPageScroll(e) {},
		beforeDestroy() {},
		methods: {
			getBaseInfo() {
				uni.showLoading({})
				api.post('api/shop/package_location', {
					onsite_id: this.id,
					work_package_id: this.packid
				}).then(res => {
					let rst = res.data
					uni.hideLoading()
					if (rst.code == 1) {
						this.baseInfo = rst.data.work_packagelist
					}
				}).catch(err => {
					uni.hideLoading()
				})
			},
			initList() {
				uni.showLoading({})
				api.post('/api/shop/workdetaikl_list', {
					page: this.page,
					onsite_id:this.id,
					work_package_id:this.packid,
					type: 1
				}).then(res => {

					uni.hideLoading()
					uni.stopPullDownRefresh(); //停止刷新
					let rst = res.data.data
					this.last_page = rst.last_page
					let temp_data = rst.data
					this.list = this.list.concat(temp_data)

				}).catch(err => {
					uni.hideLoading()
				})
			},
			gotoInfo(item) {
				uni.navigateTo({
					url: '/pages/xj/dh_xjj?id='+this.id+'&packid='+this.packid+'&site_id='+item.id
				})
			}
		}
	};
</script>

<style scoped>
	.info_box_base {
		padding: 20rpx;
		font-size: 26rpx;
	}

	.info_box_base_item {
		line-height: 50rpx;
		word-wrap: break-word;
		/* 允许在单词内换行 */
		overflow-wrap: break-word;
		/* 同上，现代浏览器推荐使用这个属性别名 */
		white-space: normal;
		/* 允许自动换行 */
	}

	.kcsj_box_item_bottom {
		font-size: 26rpx;
		margin-top: 10rpx;
	}

	.kcsj_box_item_top_right_btn {
		border: 1px solid rgb(255, 118, 10);
		color: rgb(255, 118, 10);
		font-size: 25rpx;
		border-radius: 8rpx;
		padding: 0 10rpx;
		margin-right: 10rpx;
	}

	.kcsj_box_item_top_left {
		width: 80%;
		white-space: nowrap;
		/* 确保文本在一行内显示 */
		overflow: hidden;
		/* 超出容器的文本隐藏 */
		text-overflow: ellipsis;
		/* 超出部分显示省略号 */
	}

	.kcsj_box_item_top_right {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.kcsj_box_item_top {
		display: flex;
		flex-direction: row;
		align-items: center;
		font-size: 26rpx;
		justify-content: space-between;
	}

	.kcsj_box_item {
		width: 710rpx;
		margin: 0 auto;
		border: 1px solid rgb(235, 229, 229);
		padding: 20rpx;
		margin-top: 20rpx;
		border-radius: 10rpx;
	}

	page {
		background-color: #fff;
	}
</style>